package gummachine.remote;

import gummachine.GumballMachine;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

/**
 * description:
 *  开启糖果机远程服务
 * @author Yuanml on 2020/10/29 17:18
 */
public class RemoteServer {
    public static void main(String[] args) throws RemoteException, MalformedURLException {
        System.out.println("开启糖果机远程服务...");
        GumballMachineRemote gumballMachineRemote0 = new GumballMachine("gumballMachineRemote0",200);
        GumballMachineRemote gumballMachineRemote1 = new GumballMachine("gumballMachineRemote1",562);
        GumballMachineRemote gumballMachineRemote2 = new GumballMachine("gumballMachineRemote2",312);
        LocateRegistry.createRegistry(1099);
        Naming.rebind(gumballMachineRemote0.getLocation(), gumballMachineRemote0);
        Naming.rebind(gumballMachineRemote1.getLocation(), gumballMachineRemote1);
        Naming.rebind(gumballMachineRemote2.getLocation(), gumballMachineRemote2);
    }
}
